package com.gxwzxy.medic.service.Impl;

import java.util.List;

import com.gxwzxy.medic.dao.InstitutionDao;
import com.gxwzxy.medic.dao.Impl.InstitutionDaoImpl;
import com.gxwzxy.medic.entity.Institution;
import com.gxwzxy.medic.service.InstitutionService;
import com.gxwzxy.medic.until.PageBean;

public class InstitutionServiceImpl implements InstitutionService {

	/**
	 * 农合经办点分页展示
	 */
	@Override
	public void pageInstitution(PageBean<Institution> pu) {
		InstitutionDao id = new InstitutionDaoImpl();
		//查询数据库表获取记录总数
		int totalCount = id.findInSize();
		//使用记录总数计算PageBean中其他属性：totalPageCount(总页数)，numbers(页数集合)
		pu.setTotalCount(totalCount);
		//调用Dao层获取指定页数的学生数据，并放入PageBean的list属性
		int start = pu.getStartRow();
		int size = pu.getSize();
		List<Institution> lu = id.findInsIndex(start,size);
		pu.setList(lu);
	}
	
	/**
	 * 查询所有经办点
	 */
	@Override
	public List<Institution> findAllIns() {
		InstitutionDao id = new InstitutionDaoImpl();
		return id.findAllIns();
	}

	/**
	 * 添加新经办机构
	 */
	@Override
	public boolean saveIns(String agenName, String areaCode, String areagrade) {
		InstitutionDao id = new InstitutionDaoImpl();
		return id.saveIns(agenName,areaCode,areagrade);
	}

	/**
	 * 根据agenCode修改经办机构
	 */
	@Override
	public boolean updateIns(String agenCode, String agenName) {
		InstitutionDao id = new InstitutionDaoImpl();
		return id.updateIns(agenCode,agenName);
	}

	/**
	 * 根据agenCode删除经办机构
	 */
	@Override
	public boolean deleteIns(String agenCode) {
		InstitutionDao id = new InstitutionDaoImpl();
		return id.deleteIns(agenCode);
	}

}
